package OfferLanQiaoBei.a_13届蓝桥真题;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/*
小蓝老师教的编程课有N名学生，编号依次是1...N.
第i号学生这学期剛题的数量是A.
对于每一名学生，请你计算他至少还要再刷多少道题，
才能使得全班刷题比他多的学生数不超过刷题比他少的学生数。
case1
5
12 10 15 20 6
0 3 0 0 7

case2
5
1 10 20 20 30
19 10 0 0 0

case3
5
1 1 1 1 2
1 1 1 1 0

5
1 1 1 1 1
0 0 0 0 0 
 */
public class d最少刷题数自己暴力 {
	public static void main(String[] args) {
		d最少刷题数自己暴力 test = new d最少刷题数自己暴力();
		test.useDeal();
	}
	
	public void useDeal() {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		student[] students = new student[N];
		for (int i = 0; i < N; i++) {
			students[i] = new student(i, scanner.nextInt(), -1);
		}
		student[] res = deal(students, N);
		for (int i = 0; i < N; i++) {
			if (i == N - 1) {
				System.out.print(res[i].need);
				return;
			}
			System.out.print(res[i].need + " ");
		}
	}
	
	public student[] deal(student[] students, int N) {
		int count = 0;
		Arrays.sort(students);
		if (N % 2 != 0) {
			int mid = (N - 1) / 2;
			for (int i = 0; i < N; i++) {
				if (students[i].number == students[mid].number) {
					count++;
				}
			}
			if (count == N) {
				for (int i = 0; i < N; i++) {
					students[i].need = 0;
				}
			} else {
				if (count > N / 2) {
					for (int i = 0; i < N; i++) {
						if (students[i].number <= students[mid].number) {
							students[i].need = students[mid].number + 1 - students[i].number;
						} else {
							students[i].need = 0;
						}
					}
				} else {
					if (students[mid].number == students[mid - 1].number || students[mid].number == students[mid + 1].number) {
						for (int i = 0; i < mid; i++) {
							students[i].need = students[mid].number - students[i].number;
						}
					} else {
						for (int i = 0; i < mid; i++) {
							students[i].need = students[mid].number + 1 - students[i].number;
						}
					}
					for (int i = mid; i < N; i++) {
						students[i].need = 0;
					}
				}
			}
			

		} else {
			int mid = N / 2;
			for (int i = 0; i < N; i++) {
				if (students[i].number == students[mid].number) {
					count++;
				}
			}
			if (count == N) {
				for (int i = 0; i < N; i++) {
					students[i].need = 0;
				}
			} else {
				if (count >= N / 2) {
					for (int i = 0; i < N; i++) {
						if (students[i].number <= students[mid].number) {
							students[i].need = students[mid].number + 1 - students[i].number;
						} else {
							students[i].need = 0;
						}
					}
				} else {
					if (students[mid].number == students[mid - 1].number || students[mid].number == students[mid + 1].number) {
						for (int i = 0; i < mid; i++) {
							students[i].need = students[mid].number - students[i].number;
						}
					} else {
						for (int i = 0; i < mid; i++) {
							students[i].need = students[mid].number + 1 - students[i].number;
						}
					}
					for (int i = mid; i < N; i++) {
						students[i].need = 0;
					}
				}
			}
			
			
			
			
		}
		Arrays.sort(students, new Comparator<student>() {
			@Override
			public int compare(student o1, student o2) {
				int x = o1.index - o2.index;
				return x;
			}
		});
		return students;
	}
	
	private static class student implements Comparable<student> {
		int index;
		int number;
		int need;
		public student(int index, int number, int need) {
			this.index = index;
			this.number = number;
			this.need = need;
		}
		@Override
		public int compareTo(student o) {
			int x = this.number - o.number;
			if (x == 0) {
				return this.index - o.index;
			}
			return x;
		}
	}
}
